<template>
<div>
<!--  用印申请   -->
  <el-form :inline="true" :model="sealForm" class="demo-form-inline">
    <el-row>
      <el-form-item label="领用人:">
        <el-input v-model="sealForm.applyforRecipient" placeholder="请输入领用人"></el-input>
      </el-form-item>
      <el-form-item >
        <el-select v-model="sealForm.applyforApprovalStatus" placeholder="审批状态">
          <el-option label="审批状态" value=""></el-option>
          <el-option label="审批中" value="1"></el-option>
          <el-option label="审批通过" value="2"></el-option>
          <el-option label="审批不通过" value="3"></el-option>
        </el-select>
      </el-form-item>

      <el-form-item label="领用日期:">
        <el-date-picker
            v-model="dateData"
            type="daterange"
            format="yyyy-MM-dd"
            value-format="yyyy-MM-dd"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="querySeal">查询</el-button>
      </el-form-item>
      <el-form-item>
        <el-button
            type="primary"
            icon="el-icon-printer"
            class="btn-no"
            v-print="printObj">打印
        </el-button>
      </el-form-item>
    </el-row>
  </el-form>

  <!--  打印的内容  -->
  <div id="printMe" style="width: 99%">

    <p style="text-align: center;font-size: 30px;font-weight:bold">心心念念事务所 （合计：<span>{{pageData.total}}</span>个）</p>

    <el-table
        :data="sealData"
        style="width: 100%">
      <el-table-column
          prop="case_no"
          label="案号">
      </el-table-column>
      <el-table-column
          prop="applyfor_receive"
          :formatter="dateFun"
          label="领用日期">
      </el-table-column>
      <el-table-column
          prop="applyfor_approval_status"
          :formatter="statusFun"
          label="审批状态">
      </el-table-column>
      <el-table-column
          prop="applyfor_recipient"
          label="领用人">
      </el-table-column>
      <el-table-column
          prop="file_name"
          label="用印事项">
      </el-table-column>
      <template slot="empty">
        <div  style="height: 10%">
          <span>没有找到匹配数据</span>
        </div>
      </template>
    </el-table>
<!-- 打印结束  -->
  </div>
    <div style="height: 30px"></div>

  <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :page-sizes="[2, 4, 6, 8,50]"
      layout="total, sizes, prev, pager, next, jumper"
      :total="pageData.total">
  </el-pagination>


</div>
</template>

<script>
export default {
  name: "Seal",
  data(){
    return{
      dateData:[], // 表单时间
      pageData:{}, // 存放分页数据
      sealForm: { // 用印查询表单
        applyforApprovalStatus:'',
        pageCur: "1",//页码
        pageSize: "2",//每页显示多少
        dateStart: "",// 开始时间
        dateEnd: "",// 结束时间
      },
      sealData:[], // 用印数据
      printObj: { // 打印
        id: "printMe",
        // popTitle: "打印模板",
        extraHead: '<meta http-equiv="Content-Language"content="zh-cn"/>',
      },

    }
  },
  created() {
this.querySeal();
  },
  methods:{
    querySeal(){ // 用印查询

      if(this.dateData.length > 0){ // 如果高级查询有日期进入
        // 获取时间区间
        this.sealForm.dateStart = this.dateData[0]
        this.sealForm.dateEnd = this.dateData[1]
      }
      const loading = this.$loading({
        lock: true,
        text: '正在载入...',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)'
      });
      this.$http.get('statistics/sealTongji',{params:this.sealForm})
      .then(res => {
        setTimeout(() => {
          loading.close();
        });
        this.sealData = res.data.data.list
        this.pageData = res.data.data
      })
      .catch()
    },
    handleSizeChange(val){
      this.sealForm.pageSize=val
      this.querySeal();
    },
    handleCurrentChange(val){
      this.sealForm.pageCur=val
      this.querySeal()
    },
    statusFun(data){
      return data.applyfor_approval_status == '1' ? '审批中' : data.applyfor_approval_status == '2' ? '审批通过' : data.applyfor_approval_status == '3' ? '审批不通过' : '-'
    },
    dateFun(data){

      return this.$date.formatDate( new Date(data.applyfor_receive),'yyyy-MM-DD hh:mm:ss') ;
    },
  }
}
</script>

<style scoped>

</style>